<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.jhs.kjs.dto.MenuDTO"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.jhs.kjs.dto.AdminBoardPagingDTO"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@page import="com.jhs.kjs.model.UserModel"%>
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<html>
<head>
<title>알당</title>
<meta http-equiv="Content-Type" content="textml; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi" />
<meta name="viewport" content="initial-scale=1.0; maximum-scale=2.0; minimum-scale=1.0; user-scalable=1;" />
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<%@ include file="/WEB-INF/views/include/common.jsp" %>
<link href="${cssUrl}/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="head" onload="javascript:this.width=this.document.body.clientWidth;">
	<img src="${imgUrl}/m/top.jpg" border="0" usemap="#Map1" id='change'/>
	<map name="Map1">
		<!-- logo -->
		<area href="/m/mobileMain" shape="rect" coords="5,8,56,53">
		<!-- search -->
		<area href="#" shape="rect" coords="159,14,208,47">
		<!-- login -->
		<area href="/m/login" shape="rect" coords="213,14,262,47">
		<!-- menu -->
		<area href="#" shape="rect" coords="267,14,316,47">
	</map>
</div>
<div id="main_visual" onload="javascript:this.width=this.document.body.clientWidth;">
	<img src="${imgUrl}/m/main_visual.jpg" width="100%" border="0" />
</div>
<script>	
	function tab(tabIndex, idx) {
		$("#tab"+tabIndex).hide();
		$("#tab"+idx).show();
	}
</script>
<div id="main_content" onload="javascript:this.width=this.document.body.clientWidth;">
	<!-- 1_1 -->
<%
	HttpSession session = request.getSession();
	List<MenuDTO> menu = (List<MenuDTO>)request.getAttribute("userBoardList");

	Map<String, List<AdminBoardPagingDTO>> boardMap = (Map<String, List<AdminBoardPagingDTO>>)request.getAttribute("boardList");
	Iterator<String> boardIt = boardMap.keySet().iterator();
	String mapKey = "";
	int i = 1, gap = 1;
	String display = "", classOn = "";
	while(boardIt.hasNext()){
		mapKey = boardIt.next();
		List<AdminBoardPagingDTO> boardList = boardMap.get(mapKey);
		
		if(i % 3 == 1) {
			display = "";			
		} else {
			display = "none;";			
		}
%>
	<div id="tab<%=i %>" class="board" style="display:<%=display%>">
		<div class="tit">
			<ul>
			<% 
				for (int idx=0; idx <= 2; idx++) {
					if((idx+gap) == i) {
						classOn = "class='on'";
					} else {
						classOn = "";
					}
			%>
			
				<% if ((idx+gap)-1 != menu.size()) { %>
					<li><a href="javascript:tab(<%=i %>, <%=idx+gap %>);" <%=classOn %>><%=menu.get((idx+gap)-1).getMenuName() %></a></li>
				<% } %>
				<%-- <li><a href="javascript:tab<%=tabIndex %>(<%=idx+gap %>);"><%=idx+gap %><%=menu.size() %></a></li> --%>
				<%-- <li class="rig"><a href="javascript:tab<%=tabIndex %>(<%=idx+gap %>);">메뉴</a></li> --%>
			<% } %>
			</ul>
		</div>
		<ul>
<% 			for(AdminBoardPagingDTO board : boardList){%>
			<li><a href="#" onclick="goView(<%=board.getBoardType() %>,<%=board.getTextID() %>);"><%=board.getTitle() %></a></li>
			<!-- <li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li> -->
<%			} %>
		</ul>
	</div>
<% 
	if ( (i % 3) == 0) {
		gap += 3;		
	}	
	i++; 
	} 
%>
	<!-- 1_2 -->
	<!-- <div id="tab2" class="board" style="display:none;">
		<div class="tit">
			<ul>
				<li><a href="javascript:tab1(1);">육아소송</a></li>
				<li><a href="javascript:tab1(2);" class="on">이혼자료</a></li>
				<li class="rig"><a href="javascript:tab1(3);">메뉴</a></li>
			</ul>
		</div>
		<ul>
			<li><a href="#">이혼자료</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
		</ul>
	</div>
	1_3
	<div id="tab3" class="board" style="display:none;">
		<div class="tit">
			<ul>
				<li><a href="javascript:tab1(1);">육아소송</a></li>
				<li><a href="javascript:tab1(2);">이혼자료</a></li>
				<li class="rig"><a href="javascript:tab1(3);" class="on">메뉴</a></li>
			</ul>
		</div>
		<ul>
			<li><a href="#">메뉴</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
		</ul>
	</div>
	2_1
	<div id="tab4" class="board">
		<div class="tit">
			<ul>
				<li><a href="javascript:tab2(4);" class="on">육아소송</a></li>
				<li><a href="javascript:tab2(5);">이혼자료</a></li>
				<li class="rig"><a href="javascript:tab2(6);">메뉴</a></li>
			</ul>
		</div>
		<ul>
			<li><a href="#">육아소송</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
		</ul>
	</div>
	2_2
	<div id="tab5" class="board" style="display:none;">
		<div class="tit">
			<ul>
				<li><a href="javascript:tab2(4);">육아소송</a></li>
				<li><a href="javascript:tab2(5);" class="on">이혼자료</a></li>
				<li class="rig"><a href="javascript:tab2(6);">메뉴</a></li>
			</ul>
		</div>
		<ul>
			<li><a href="#">이혼자료</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
		</ul>
	</div>
	2_3
	<div id="tab6" class="board" style="display:none;">
		<div class="tit">
			<ul>
				<li><a href="javascript:tab2(4);">육아소송</a></li>
				<li><a href="javascript:tab2(5);">이혼자료</a></li>
				<li class="rig"><a href="javascript:tab2(6);" class="on">메뉴</a></li>
			</ul>
		</div>
		<ul>
			<li><a href="#">메뉴</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
		</ul>
	</div>
	3_1
	<div id="tab7" class="board">
		<div class="tit">
			<ul>
				<li><a href="javascript:tab3(7);" class="on">육아소송</a></li>
				<li><a href="javascript:tab3(8);">이혼자료</a></li>
				<li class="rig"><a href="javascript:tab3(9);">메뉴</a></li>
			</ul>
		</div>
		<ul>
			<li><a href="#">육아소송</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
		</ul>
	</div>
	3_2
	<div id="tab8" class="board" style="display:none;">
		<div class="tit">
			<ul>
				<li><a href="javascript:tab3(7);">육아소송</a></li>
				<li><a href="javascript:tab3(8);" class="on">이혼자료</a></li>
				<li class="rig"><a href="javascript:tab3(9);">메뉴</a></li>
			</ul>
		</div>
		<ul>
			<li><a href="#">이혼자료</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
		</ul>
	</div>
	3_3
	<div id="tab9" class="board" style="display:none;">
		<div class="tit">
			<ul>
				<li><a href="javascript:tab3(7);">육아소송</a></li>
				<li><a href="javascript:tab3(8);">이혼자료</a></li>
				<li class="rig"><a href="javascript:tab3(9);" class="on">메뉴</a></li>
			</ul>
		</div>
		<ul>
			<li><a href="#">메뉴</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
			<li><a href="#">안녕하세요. 알고있어야 당하지 않는다.</a></li>
		</ul>
	</div> -->
	<div class="main_img">
		<img src="${imgUrl}/m/main_img.jpg" border="0" usemap="#main_img"/>
		<map name="main_img">
			<area shape="rect" coords="0,0,102,92" href="javascript:goBoardList(1)" />
			<area shape="rect" coords="102,0,206,92" href="javascript:goBoardList(2)" />
			<area shape="rect" coords="206,0,309,92" href="javascript:goBoardList(3)" />
		</map>
	</div>
</div>
<div id="foot" onload="javascript:this.width=this.document.body.clientWidth;">
	<div class="foot_menu">
		<p><a href="#">자문변호사</a> | <a href="#">오픈매장</a> | <a href="#">할인매장</a> | <a href="#">미아방지</a> | <a href="#">부동산및구인구직</a></p>
	</div>
	<div class="foot_copy">
		<p>copyright(c) 2014 clipartkorea all rights reserved.</p>
	</div>
</div>
<form style="display:none;" name="frm" id="frm" method="post">
	<input type="text" id="menuIndex" name="menuIndex">
	<input type="text" id="textID" name="textID">
</form>
<script type="text/javascript">
function goView(menuIndex, textID) {		
	if(menuIndex > 4) {
		//로그인 체크
		<% if(session.getAttribute(UserModel.USER_SESSION_INFO) == null) {%> 
			$("#menuIndex").val(menuIndex);
			$("#textID").val(textID);
			$("#frm").attr("action", "/m/userBoardView");
		  	$("#frm").submit();
		  	return;
		<% }%>
		
		var myPoint = 0, boardPoint = 0;
		var isUseCheck = "N";
		
		var url='/board/getMyInfo.json';
		var param = "textID="+textID+"&menuIndex="+menuIndex;
		
		AjaxPost(url, param, function(data){
			myPoint = data.userData.point; //내 금액
			boardPoint = data.boardData.usePoint; //게시글의 구매금액
			isUseCheck = data.usePointCheck; //구매체크
			<% if(!"40".equals(session.getAttribute(UserModel.USER_LEVEL))){ %> 	
			if(myPoint < boardPoint) {
				alert('포인트가 부족합니다.');
				return;			
			}
			
			if(isUseCheck != 'Y') {
				if(!confirm('구매 하시겠습니까?')) {
					return;
				}
			}
			<% } %>
			$("#menuIndex").val(menuIndex);
			$("#textID").val(textID);
			$("#frm").attr("action", "/m/boardView");
		  	$("#frm").submit();
		});	
	} else {
		$("#menuIndex").val(menuIndex);
		$("#textID").val(textID);
		$("#frm").attr("action", "/m/boardView");
	  	$("#frm").submit();
	}
  	return false;
}
function goBoardList(menuIndex) {
	$("#menuIndex").val(menuIndex);
	var url = "/m/boardListMain";	
	
	$("#frm").attr("action", url);
	$("#frm").submit();
	
	return false;
}
</script>
</body>
</html>